//
//  ImagePickerControllerDelegate.m
//  ALittleReminder
//
//  Created by George on Nov.12/2011.
//

#import "ImagePickerControllerDelegate.h"

@implementation ImagePickerControllerDelegate
@synthesize alert;

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    //Set alert with the picked image
    if (alert) {
        //NSLog(@"Selected image:%@",info);
        
        // Try getting the edited image first. If it doesn't exist then you get the original image.
            /*
        UIImage* picture = [info objectForKey:UIImagePickerControllerEditedImage];
        if (!picture) 
            picture = [info objectForKey:UIImagePickerControllerOriginalImage];             
        */
        // **You can now do something with the picture.
       
        NSURL *imageURL = [info objectForKey:UIImagePickerControllerReferenceURL]; 
        NSString *imageURLString = [imageURL absoluteString];
        //NSLog(@"imageURLString:%@",imageURLString);
        alert.imageURLString = imageURLString;
    }
    //Dismiss the image picker
    [picker dismissModalViewControllerAnimated:YES];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    //Dismiss the image picker
    [picker dismissModalViewControllerAnimated:YES];
}

@end
